<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <link rel="shortcut icon"
          href="https://static-index-4gtuqm3bfa95c963-1304825656.tcloudbaseapp.com/official-website/favicon.svg"
          mce_href="https://static-index-4gtuqm3bfa95c963-1304825656.tcloudbaseapp.com/official-website/favicon.svg"
          type="image/x-icon" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous" />
    <title></title>
    <!-- 引入外部jQuery -->
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
</head>
<!-- 使用静态值替代Thymeleaf变量 -->
<input type="hidden" th:value="${sn}" id="sn"/>
<input type="hidden" th:value="${sessionId}" id="sessionId"/>
<body>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script>
    $(document).ready(function(){
        $.ajax({
            url: '/common/read/article',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify({
                sn: $("#sn").val(),
                sessionId: $("#sessionId").val(),
            }),
            success: function(response) {
                if(response.code == 200){
                    window.location.href = response.data;
                }else{
                    // 微信生态的关闭页面
                    if (typeof WeixinJSBridge === 'undefined') {
                        document.addEventListener('WeixinJSBridgeReady', function() {
                            WeixinJSBridge.call('closeWindow');
                        }, false);
                    } else {
                        WeixinJSBridge.call('closeWindow');
                    }
                }

            },
            error: function(xhr, status, error) {
                console.error('提交失败:', error);
            },
            beforeSend:function(XMLHttpRequest){
            },
        });

    });
</script>
</body>
</html>